#include "moonnote.h"

#include <qmenubar.h>
#include <qlayout.h>
#include <qsplitter.h>
#include <qtoolbutton.h>
#include <qtoolbar.h>


#include "SideBar.h"
#include "NoteListWidget.h"
#include "EditView.h"
#include "strings.h"

MoonNote::MoonNote(QWidget *parent)
	: QMainWindow(parent)
{

	sideBar = new SideBar();
	noteListWidget = new NoteListWidget(); 
	editView = new EditView();

	QSplitter* splitter = new QSplitter(Qt::Horizontal);
	
	splitter->addWidget(sideBar); 
	splitter->addWidget(noteListWidget);
	splitter->addWidget(editView);

	int width = splitter->width();
	QList<int> sizes;
	sizes << width / 6 << width / 6 << width * 2 / 3;
	splitter->setSizes(sizes);
	
	setCentralWidget(splitter);

	showMaximized();

	createMenu();
	createToolBar();
}

MoonNote::~MoonNote()
{

}

void MoonNote::createMenu()
{
	fileMenu = menuBar()->addMenu(STRINGS::FILE);
	editMenu = menuBar()->addMenu(STRINGS::EDIT);
	toolMenu = menuBar()->addMenu(STRINGS::TOOL);
	helpMenu = menuBar()->addMenu(STRINGS::HELP);

	
	
}

void MoonNote::createToolBar()
{
	
	QToolBar* toolbar = addToolBar(STRINGS::STANDARD);
	toolbar->setIconSize(QSize(40, 40));

	newNoteBtn = new QToolButton();
	newNoteBtn->setIcon(QIcon("Resources/newnote.png"));
	newNoteBtn->setToolTip(STRINGS::NEW_NOTE);

	saveNoteBtn = new QToolButton();
	saveNoteBtn->setIcon(QIcon("Resources/save.png"));
	saveNoteBtn->setToolTip(STRINGS::SAVE);

	QToolButton* switchEditBtn = new QToolButton();
	switchEditBtn->setIcon(QIcon("Resources/switch.png"));
	switchEditBtn->setToolTip(STRINGS::SWITCH_EDIT);
	
	toolbar->addWidget(newNoteBtn);
	toolbar->addWidget(saveNoteBtn);
	toolbar->addWidget(switchEditBtn);

	connect(newNoteBtn, SIGNAL(clicked()), sideBar, SLOT(addNote()));
	connect(newNoteBtn, SIGNAL(clicked()), editView, SLOT(createNote()));
	
	connect(saveNoteBtn, SIGNAL(clicked()), editView, SIGNAL(saveNote()));
}

void MoonNote::createAction()
{
	//newNoteAction = new QAction(this);

}


